﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Wicresoft.SelfService.WFInterface;

namespace Wicresoft.SelfService.WFHost.Code
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class ApproveFlow : IApproveFlow
    {
        public RequestResult Create(RequestParam requestParam)
        {
            return new ApproveFlowHost().CreateAndRun(requestParam);
        }

        public ActionResult Update(ActionParam actionParam)
        {
            return new ApproveFlowHost().UpdateForApprove(actionParam);
        }

        public RollBackResult RollBack(RollBackParam rollBackParam)
        {
            ActionResult ar = new ApproveFlowHost().UpdateForApprove(
                new ActionParam
                {
                    FlowInstanceId = rollBackParam.FlowInstanceId,
                    CurrentStep = rollBackParam.CurrentStep,
                    Action = "RollBack",
                    SecurityCode = rollBackParam.SecurityCode,
                    RequestCode = rollBackParam.RequestCode
                });
            return new RollBackResult
                   {
                       IsSuccess = ar.ErrorMsg == null ? true : false,
                       actionResult = ar
                   };
        }
    }
}
